<#assign pageName="上传流程模型">
<@override name="head-styles">
</@override>
<@override name="page-content">
    <form class="layui-form padding-10" lay-filter="formFlowModelUpload" >
        <div class="site-tips site-text">
            <p>支持文件格式：</b>zip、bar、bpmn、bpmn20.xml</p>
        </div>
        <div class="layui-tab-item layui-show align-center margin-10-0">
            <div class="layui-upload-drag" id="uploadFile">
                <i class="layui-icon"></i>
                <p>点击上传，或将文件拖拽到此处</p>
                <div class="layui-hide" id="uploadView">
                    <hr>
                    <div alt="上传成功后渲染"></div>
                </div>
                <input class="layui-upload-file" type="file" accept="" name="file">
            </div>
        </div>
        <div class="layui-form-item align-center">
            <div class="margin-10-0">
                <button id="uploadBtn" class="layui-btn layui-btn-disabled" type="button">
                    确认上传
                </button>
            </div>
        </div>
    </form>
</@override>
<@override name="page-scripts">
    <script>
    $(function(){
        layui.use(['form','layer','upload','jquery'], function(){
            var layer=layui.layer;
            var form = layui.form;
            var upload = layui.upload;
            var $ =layui.jquery;
            var files;
            upload.render({
                elem: '#uploadFile'
                ,url: '${contextPath}/workflow/deploy/upload'
                ,multiple: false
                ,auto:false
                ,accept: 'file'
                ,exts:'zip|bar|bpmn|bpmn20.xml'
                ,bindAction:"#uploadBtn"
                ,size: 2*1024
                ,choose: function (obj) {
                    files = obj.pushFile();
                    $('#uploadBtn').removeClass("layui-btn-disabled");
                    obj.preview(function (index, file, result) {
                        $('#uploadView').children("div").text(file.name);
                        $('#uploadView').removeClass("layui-hide");
                    })
                }
                ,done: function(res,index,upload){
                    if(res.code == '0'){
                        layer.msg('上传成功！');
                        delete files[index];
                        setTimeout(function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                            window.parent.location.reload();
                        }, 1500);
                    }else{
                        layer.msg("上传失败，再重新选择一遍吧！")
                    }
                }
                ,error:function(){
                    layer.msg("好像出问题了，刷新一下试试吧！")
                }
            });
        });
    })
    </script>
</@override>
<@extends name="/layout/basepage.html"/> 